﻿using System;
using System.Collections.Generic;
using System.Linq;
using NHibernate.Criterion;
using RHD.Data.DAO;
using RHD.Data.Model;
using Spring.Transaction.Interceptor;

namespace RHD.Data.NHibernate {
	public class UsersDAOHibernate : GenericDAOHibernate<Users, Int32>, IUsersDAO {

		#region IUsersDA0 Members

		[Transaction(ReadOnly = true)]
		public Users GetByEmail(string email) {
			return CurrentSession.CreateCriteria(typeof(Users)).Add(Restrictions.Eq("Email", email)).List<Users>().FirstOrDefault();
		}

		[Transaction(ReadOnly = true)]
		public IList<Users> GetAllActiveUser() {
			return CurrentSession.CreateCriteria(typeof(Users)).Add(Restrictions.Eq("Active", true)).List<Users>();
		}

		#endregion
	}
}